#ifndef __BLOB_T_H__
#define __BLOB_T_H__
#include "config.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_BDATA_PER_BLOB 1000

typedef struct bdata
{
	void*			data;
	size_t			size;
} bdata_t;

typedef struct blob
{
	bdata_t			data[MAX_BDATA_PER_BLOB];
	size_t			available;
	struct blob*	next;
} blob_t;

/**
 * allocates a new blob of data, append to existing one if ant and returns it.
**/
INLINE blob_t*		blob_create(blob_t* b);

/**
 * allocates a new raw data in blob chain and returns its address.
**/
INLINE void*		blob_alloc(blob_t* b, size_t sz);

/**
 * free all allocated data and destroy all blobs in chain.
**/
INLINE void			blob_destroy(blob_t* b);

#ifdef __cplusplus
}
#endif

#endif /* __BLOB_T_H__ */